fmdmeta_prop.func.dhxgrid={};

fmdmeta_prop.runtime_validators_dhxgrid = [["none",fmd_i18n_vld_none],
               					["NotEmpty", fmd_i18n_vld_notempty],
               					["ValidAplhaNumeric", fmd_i18n_vld_alphanumeric],
               					["ValidAplhaNumericUnderline", fmd_i18n_vld_alphanumericunderline],
               					["ValidDate", fmd_i18n_vld_date + '(yyyy-MM-dd)'],
               					["ValidDatetimeMM", fmd_i18n_vld_datetime + '(yyyy-MM-dd hh:mm)'],
               					["ValidTimeNoSS", fmd_i18n_vld_time + '(hh:mm)'],
               					["ValidInteger", fmd_i18n_vld_integer],
               					["ValidPositiveInteger", fmd_i18n_vld_positiveinteger],
               					["ValidNumeric", fmd_i18n_vld_numeric],
               					["ValidCurrency", fmd_i18n_vld_currency],
               					["ValidEmail", fmd_i18n_vld_email],
               					["ValidCnMobile", fmd_i18n_vld_cnmobile],
               					["ValidCnPhone", fmd_i18n_vld_cnphone],
               					["ValidIPv4", fmd_i18n_vld_ipv4]];

//子表单验证
fmdmeta_prop.func.dhxgrid.setColumnsValidation = function(rId, cId, grid) {
	var isEditor = fmdc.grid_prop.isEditor;
	var valichanged = false;
	
	//alert(" rId="+rId+" cId="+cId+" mode="+mode);
	var lo = fm_createCenterWindowLayout("win_prop_validation", fmd_i18n_modules.dhxgrid.validate, 800, 600, "1C", dhx_skin, "script_tag");
	fm_dhxWins.window('win_prop_validation').attachEvent('onClose', function() {
		if (valichanged) {
			dhtmlx.message({
				type:"confirm",
	            ok:fmd_i18n_b_ok,
	            cancel:fmd_i18n_b_cancel,
				text: fmd_i18n_msg_unsavedchange,
				callback: function(yes) {
					if(yes) {
						valichanged = false;
						fm_closeWindow('win_prop_validation');
					}
				}
			});
		} else {
			return true;
		}
	});
	
	var tab1 = lo.cells('a').attachTabbar();
	tab1.addTab('gui', fmd_i18n_ext_validation_gui);
	tab1.cells('gui').setActive();
	
	//get value
	var valistr = grid.cells(rId, cId).getValue();
	//alert(JSON.stringify(valistr));
	var valiv = (typeof(valistr)=='object' ? valistr : (valistr && valistr!="none" ? JSON.parse(valistr) : {})) || {};
	
	//init gui tab
	/*var lo1 = tab1.cells('gui').attachLayout('2E');
	lo1.cells("a").setText(fmd_i18n_ext_validation_auto);
	lo1.cells("b").setText(fmd_i18n_ext_validation_manual);*/
	var vgidx = 1;
	var cvgidx = 1;
	
	var vg = tab1.cells('gui').attachGrid();
	vg.setIconsPath(fmdc.imagepath);
	vg.setHeader([fmd_i18n_validator,
	              fmd_i18n_ext_validation_condition,
	              fmd_i18n_l_script,
	              fmd_i18n_ext_validation_desc,
	              "#cspan"],
                    null,
                    ["text-align:center;",
                     "text-align:center;",
                     "text-align:center;",
                     "text-align:center;",
                     "text-align:center;"]);
	vg.attachHeader("#rspan,#rspan,#rspan,"+fmd_i18n_prop_i18nname_zh+","+fmd_i18n_prop_i18nname_en);
	vg.setInitWidths("120,120,70,270,270");
	vg.setColumnIds("VALIDATION,CONDITION,SCRIPT,DESC_ZH,DESC_EN");
	vg.setColTypes("coro,rotxt,rotxt,ed,ed");
	vg.setColSorting("na,na,na,na,na");
	vg.setColAlign("left,left,left,left,left");
	vg.setColumnsVisibility("false,false,false,false,false");
	vg.setEditable(isEditor);
	vg.setLang(fmdmeta_prop.lang);
	vg.enableDragAndDrop(isEditor);
	vg.enableValidation(isEditor,isEditor);
    vg.setColValidators([null,null,null,"NotEmpty","NotEmpty"]);
	vg.init();
	vg.grid_bindColCombo(0, fmdmeta_prop.runtime_validators, {"comboSize":10, "comboWidth":260});
	
	//set data
	if (valiv.gui) {
		vg.parse(valiv.gui, 'json');
		vgidx = vg.getRowsNum() +1;
		var rn = vg.getRowsNum();
		if (rn) {//set validation for condition column
			for (var i=0; i<rn; i++) {
				if (fmdmeta_prop.validators[vg.cellByIndex(i, 0).getValue()]["condition"]) {
					vg.setCellExcellType(vg.getRowId(i), 1, 'ed');
					var val1 = "NotEmpty";
					if (fmdmeta_prop.validators[vg.cellByIndex(i, 0).getValue()]["conditionValidator"]) {
						val1+= ","+fmdmeta_prop.validators[vg.cellByIndex(i, 0).getValue()]["conditionValidator"];
					}
					vg.cellByIndex(i, 1).setAttribute("validate",val1);
				}
			}
		}
	}
	
	vg.attachEvent('onCellChanged', function(rId,cInd,nv){
		if (0==cInd && nv!='None') {
			!vg.cells(rId, 3).getValue() && vg.cells(rId, 3).setValue(fmdmeta_prop.validators[nv].zh);
			!vg.cells(rId, 4).getValue() && vg.cells(rId, 4).setValue(fmdmeta_prop.validators[nv].en);
			vg.cells(rId, 2).setValue(fmdmeta_prop.validators[nv]["func"]);
			if (fmdmeta_prop.validators[nv]["condition"]) {
				vg.setCellExcellType(rId, 1, 'ed');
				var val1 = "NotEmpty";
				if (fmdmeta_prop.validators[vg.cells(rId, 0).getValue()]["conditionValidator"]) {
					val1+= ","+fmdmeta_prop.validators[vg.cells(rId, 0).getValue()]["conditionValidator"];
				}
				vg.cells(rId, 1).setAttribute("validate",val1);
			} else {
				vg.cells(rId, 1).setAttribute("validate", '');
				vg.setCellExcellType(rId, 1, 'rotxt');
				vg.cells(rId, 1).setValue('');
				$(vg.cells(rId,1).cell).removeClass("dhtmlx_validation_error");
			}
		}
	});
	
	//gui toolbar
	if (isEditor) {
		var tbg = tab1.cells('gui').attachToolbar();
		tbg.setIconsPath(fmdc.imagepath);
		tbg.addButton('tbg_del',0,'',"delete1.gif","delete1_dis.gif");
		tbg.addButton('tbg_new',0,'',"new1.gif","new1_dis.gif");
		tbg.disableItem('tbg_del');
		tbg.attachEvent('onClick', function(tbid){
			if ('tbg_new'==tbid) {
				vg.addRow(vgidx, ["None", "", "", "", ""]);
				vgidx++;
			} else if ('tbg_del'==tbid) {
				if(vg.getSelectedRowId()!=undefined){
					vg.deleteRow(vg.getSelectedRowId());
					tbg.disableItem('tbg_del');
				}
			}
		});
		vg.attachEvent('onSelectStateChanged', function(id){
			if (id!==undefined) tbg.enableItem('tbg_del');
		});
	}
	
	//init custom tab
	var cvg = null;
	var prop_cs_editor = null;
	if (fmdc.advancedview) {
		tab1.addTab('custom', fmd_i18n_ext_validation_custom);
		var obj = document.createElement("div");
		obj.id="custom_validation_div";
		tab1.cells('custom').attachObject(obj);
		
		//signature
		var str1 = "function(";
		var arg1 = "";
		var args = {"v" : fmd_i18n_modules.dhxgrid.value};
		if (args) {
			var j=0;
			for (var i in args) {
				if (j) {
					str1 += ","; 
					arg1+=",&nbsp;";
				};
				str1 += i;
				arg1 += i + " : " + args[i];
				j++;
			}
		}
		arg1 += ",&nbsp;" + fmd_i18n_vfuncreturn;
		str1 += ")";
		var str2 = "<p style='font-size:0.75em'>"+ arg1 + "<br/>" +fmd_i18n_funcsignature + ":<br/>" + str1 + "&nbsp;{</p>";
		$('#custom_validation_div').append('<div id="prop_ace_cvg" style="height:200px;width:100%"></div>'+
				'<div id="prop_ace_cveditor_w" style="height:250px;;width:100%">' +
				'<div id="prop_ace_cveditor_desc1" style="height:50px;;width:100%">'+
				'</div><div id="prop_ace_cveditor" style="height:180px;width:100%">'+
				'</div><div style="height:20px;width:100%;font-size:0.75em">}</div></div>');
		$('#prop_ace_cveditor_desc1').append(str2);
		
		//editor
		prop_cs_editor = ace.edit("prop_ace_cveditor");
		prop_cs_editor.setTheme("ace/theme/tomorrow");
		prop_cs_editor.getSession().setMode("ace/mode/javascript");
		prop_cs_editor.resize();
		valiv.custom && prop_cs_editor.setValue(valiv.custom.func);
		prop_cs_editor.on("change", function(e){valichanged = true;});
		prop_cs_editor.setReadOnly(true);
		$('#prop_ace_cveditor_w').hide();
		
		//grid
		cvg = new dhtmlXGridObject('prop_ace_cvg');
		cvg.setIconsPath(fmdc.imagepath);
		cvg.setHeader([fmd_i18n_l_script,
		              fmd_i18n_ext_validation_desc,
		              "#cspan"],
	                    null,
	                    ["text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;"]);
		cvg.attachHeader("#rspan,"+fmd_i18n_prop_i18nname_zh+","+fmd_i18n_prop_i18nname_en);
		cvg.setInitWidths("200,270,270");
		cvg.setColumnIds("SCRIPT,DESC_ZH,DESC_EN");
		cvg.setColTypes("rotxt,ed,ed");
		cvg.setColSorting("na,na,na");
		cvg.setColAlign("left,left,left");
		cvg.setColumnsVisibility("false,false,false");
		cvg.setEditable(isEditor);
		cvg.setLang(fmdmeta_prop.lang);
		cvg.enableDragAndDrop(true);
		cvg.enableValidation(true,true);
	    cvg.setColValidators(["NotEmpty","NotEmpty","NotEmpty"]);
		cvg.init();
		
		//toolbar
		var ctb = null;
		if (isEditor) {
			ctb = tab1.cells('custom').attachToolbar();
			ctb.setIconsPath(fmdc.imagepath);
			ctb.addButton('ctb_apply', 0, fmd_i18n_vld_applyscript, "apply.gif","apply_dis.gif");
			ctb.addButton('ctb_del',0,'',"delete1.gif","delete1_dis.gif");
			ctb.addButton('ctb_new',0,'',"new1.gif","new1_dis.gif");
			ctb.disableItem('ctb_del');
			ctb.attachEvent("onClick", function(id){
				if ("ctb_apply"==id) {
					if(cvg.getSelectedRowId()!=undefined){
						cvg.cells(cvg.getSelectedRowId(), 0).setValue(prop_cs_editor.getValue());
					}
					valichanged = false;
				} else if ("ctb_del"==id) {
					if(cvg.getSelectedRowId()!=undefined){
						cvg.deleteRow(cvg.getSelectedRowId());
						ctb.disableItem('ctb_del');
						$('#prop_ace_cveditor_w').hide();
					}
				} else if ("ctb_new"==id) {
					cvg.addRow(cvgidx, ["return true;", "", ""]);
					cvgidx++;
				}
			});
			
		}
		
		cvg.attachEvent("onBeforeSelect", function(new_row,old_row){
			if (new_row!=old_row && valichanged) {
				msg(fmd_i18n_msg_plsapplyscript);
				return false;
			}
			return true;
		});
		
		cvg.attachEvent('onSelectStateChanged', function(id){
			if (id!==undefined) {
				if (isEditor) {
					ctb.enableItem('ctb_del');
				}
				prop_cs_editor.setReadOnly(!isEditor);
				prop_cs_editor.setValue(cvg.cells(id, 0).getValue());
				$('#prop_ace_cveditor_w').show();
			} else {
				prop_cs_editor.setValue('');
				prop_cs_editor.setReadOnly(true);
				$('#prop_ace_cveditor_w').hide();
			}
			valichanged = false;
		});
		
		if (valiv.custom) {
			cvg.parse(valiv.custom, 'json');
			cvgidx = cvg.getRowsNum() +1;
		}
		
	}
	
	//readonly?
	if (isEditor) {
		//toolbar
		var tb = lo.cells("a").attachToolbar();
		tb.setIconsPath(fmdc.imagepath);
		tb.addButton('ok', 0, fmd_i18n_b_ok, 'ok.png', null);
		tb.attachEvent("onClick", function(id){
			if ("ok"==id) {
				//gui
				var rn = vg.getRowsNum();
				var gdata = {rows:[]};
				if (rn) {
					var idx = 1;
					for (var i=0; i<rn; i++) {
						var data = [];
						data[0] = vg.cellByIndex(i, 0).getValue();
						data[1] = vg.cellByIndex(i, 1).getValue();
						data[2] = vg.cellByIndex(i, 2).getValue();
						data[3] = vg.cellByIndex(i, 3).getValue();
						data[4] = vg.cellByIndex(i, 4).getValue();
						if (data[0]=='None') {
							msg(fmd_i18n_msg_plscompleteinfo);
							return;
						}
						//alert(i+"="+vg.validateCell(vg.getRowId(i), 1));
						if (vg.cellByIndex(i, 1).getAttribute('validate') && vg.validateCell(vg.getRowId(i), 1)===false) {
							msg(fmd_i18n_msg_plscompleteinfo);
							return;
						}
						if (!data[2]) {
							msg(fmd_i18n_msg_plscompleteinfo);
							return;
						}
						if (!data[3]) {
							msg(fmd_i18n_msg_plscompleteinfo);
							return;
						}
						gdata.rows.push({"id":idx++, "data": data});
					}
				}
				valiv.gui = gdata;
				//custom
				if (fmdc.advancedview) {
					if(cvg.getSelectedRowId()!=undefined && valichanged){
						cvg.cells(cvg.getSelectedRowId(), 0).setValue(prop_cs_editor.getValue());
						valichanged = false;
					}
					var cgdata = {rows:[]};
					var rn1 = cvg.getRowsNum();
					if (rn1) {
						var cidx = 1;
						for (var j=0; j<rn1; j++) {
							var data1 = [];
							data1[0] = cvg.cellByIndex(j, 0).getValue();
							data1[1] = cvg.cellByIndex(j, 1).getValue();
							data1[2] = cvg.cellByIndex(j, 2).getValue();
							if (!data1[0]) {
								msg(fmd_i18n_msg_plscompleteinfo);
								return;
							}
							if (!data1[1]) {
								msg(fmd_i18n_msg_plscompleteinfo);
								return;
							}
							if (!data1[2]) {
								msg(fmd_i18n_msg_plscompleteinfo);
								return;
							}
							cgdata.rows.push({"id":cidx++, "data": data1});
						}
					}
					valiv.custom = cgdata;
				}
				
				//add type
				valiv.type = 'validation';
				//add input index
				valiv.inputindex = 0;
				grid.cells(rId, cId).setValue(valiv);
				fm_closeWindow("win_prop_validation");
			}
		});
	}
};

//set grid settings
fmdmeta_prop.func.dhxgrid.columnSetting = function(rId, cId) {

	//检查是否选定了数据绑定
	var modelName = fmdc.version.formdata.propconf[designer.getSelected().attr("id")].model;
	if (!modelName) {
		msg(fmd_i18n_modules.dhxgrid.msg_plsselmodel);
		return;
	}
	
	var w1 = fm_createCenterWindow('wid_columnSetting', fmd_i18n_modules.dhxgrid.gridsetting, 800, 600);
	
	var lo1 = w1.attachLayout("2E");
	lo1.cells('a').hideHeader();
	lo1.cells('b').hideHeader();
	lo1.cells('b').setHeight(60);
	
	var str1 = [{ type:"block" , name:"form_block_1", offsetLeft:(dhx_skin=="dhx_web"?"333":"343"), offsetTop:"0", 
			list:[{ type:"button" , name:"fb_ok", value:fmd_i18n_b_ok, inputTop:10}]}];
	var fm2 = lo1.cells('b').attachForm(str1);
	
	//grid
	var ragrid = lo1.cells('a').attachGrid();
	ragrid.extIconPath = resloc + fmdmeta_prop.gridconf.extIconPath;
	ragrid.setHeader([fmd_i18n_l_no,
	                    fmd_i18n_modules.dhxgrid.colname,
						fmd_i18n_modules.dhxgrid.coltype,
						fmd_i18n_modules.dhxgrid.coldesc,
						"#cspan",
						fmd_i18n_modules.dhxgrid.coleditortype,
						fmd_i18n_modules.dhxgrid.colmeta,
						fmd_i18n_modules.dhxgrid.colmetasource,
						fmd_i18n_modules.dhxgrid.coldefault,
						fmd_i18n_modules.dhxgrid.hidden,
						fmd_i18n_modules.dhxgrid.width,
						fmd_i18n_modules.dhxgrid.align,
						fmd_i18n_modules.dhxgrid.sort,
						fmd_i18n_modules.dhxgrid.format,
						fmd_i18n_modules.dhxgrid.validate,
						fmd_i18n_modules.dhxgrid.readonly,
						fmd_i18n_modules.dhxgrid.maxlength],
	                    null,
	                    ["text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;"]);
	ragrid.attachHeader("#rspan,#rspan,#rspan,"+fmd_i18n_modules.dhxgrid.zh+","+fmd_i18n_modules.dhxgrid.en+",#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan");
	ragrid.setInitWidths("40,100,60,120,120,80,80,100,80,45,45,60,80,80,80,80,80");
	ragrid.setColumnIds("NO,NAME,TYPE,ZH,EN,EDITORTYPE,META,METASOURCE,DEFAULT,HIDDEN,WIDTH,ALIGN,SORT,FORMAT,VALIDATE,READONLY,MAXLENGTH");
	//ragrid.setColValidators([null,null,null,"NotEmpty","NotEmpty",null,null,null,null,null,"ValidPositiveInteger",null,null,null,null,null]);
	ragrid.setColTypes("ro,ro,ro,ed,ed,ro,ro,ro,ed,ch,ed,ro,ro,ro,ro,ch,ro");
	ragrid.setColSorting("na,na,na,na,na,na,na,na,na,na,na,na,na,na,na,na,na");
	ragrid.setColumnsVisibility("false,false,false,false,false,false,false,false,false,false,false,false,true,false,false,false,true");
	ragrid.setColAlign("center,center,left,left,left,center,left,left,left,center,right,center,center,center,center,center,right");
	ragrid.setLang(fmdmeta_prop.lang);
	ragrid.setEditable(fmdc.grid_prop.isEditor);
	ragrid.isEditor = fmdc.grid_prop.isEditor;
	ragrid.enableValidation(true,true);
	ragrid.enableEditEvents(fmdc.grid_prop.isEditor,false,false);
	ragrid.enableDragAndDrop(true);
	ragrid.init();
	
	var idxTYPE=2;
	var idxZH=3;
	var idxEN=4;
	var idxEDITORTYPE=5;
	var idxMETA=6;
	var idxMETASOURCE=7;
	var idxDEFAULT=8;
	var idxHIDDEN=9;
	var idxWIDTH=10;
	var idxALIGN=11;
	var idxSORT=12;
	var idxFORMAT=13;
	var idxVALIDATE=14;
	var idxREADONLY=15;
	var idxMAXLENGTH=16;
	
	//重置序号
	ragrid.attachEvent("onDrop", function(sId,tId,dId,sObj,tObj,sCol,tCol){
		var rn = this.getRowsNum();
		for (var i=0; i<rn; i++) {
			this.cellByIndex(i, 0).setValue(i+1);
		}
	});
	
	fm2.attachEvent("onButtonClick", function(btid) {
		if (btid=='fb_ok') {
			var newval = [];
			var rn = ragrid.getRowsNum();
			var valid = true;
			for (var i=0; i<rn; i++) {
				var rid = ragrid.getRowId(i);
				//验证所有列
				for (var j=3; j<=idxSORT; j++) {
					if (ragrid.cells(rid, j).getAttribute("validate") && !ragrid.validateCell(rid, j)) {
						valid = false;
					}
				}
				var r = {};
				r.id = rid;
				r.type = fmdc.models[modelName].attrs[rid].type;
				r.zh = ragrid.cells(rid, idxZH).getValue();
				r.en = ragrid.cells(rid, idxEN).getValue();
				r.editortype = ragrid.cells(rid, idxEDITORTYPE).getValue();
				r.meta = ragrid.cells(rid, idxMETA).getValue();
				r.metasource = ragrid.cells(rid, idxMETASOURCE).getValue();
				r["default"] = ragrid.cells(rid, idxDEFAULT).getValue();
				r.hidden = ragrid.cells(rid, idxHIDDEN).getValue();
				r.width = ragrid.cells(rid, idxWIDTH).getValue();
				r.align = ragrid.cells(rid, idxALIGN).getValue();
				r.sort = ragrid.cells(rid, idxSORT).getValue();
				r.format = ragrid.cells(rid, idxFORMAT).getValue();
				r.validate = ragrid.cells(rid, idxVALIDATE).getValue();
				r.readonly = ragrid.cells(rid, idxREADONLY).getValue();
				r.maxlength = ragrid.cells(rid, idxMAXLENGTH).getValue();
				newval.push(r);
			}
			if (!valid) {
				msg(fmd_i18n_modules.dhxgrid.msg_validateErr);
				return;
			}
			fmdc.grid_prop.cells(rId, cId).setValue(newval, true);	//第二个参数必须为true，触发事件
			w1.close();
		}
	});
	
	//load existing
	var existingData = fmdc.version.formdata.propconf[designer.getSelected().attr("id")].gridsetting;
	var ov = typeof(existingData)=='string' ? JSON.parse(existingData) : existingData;
	
	//加载顺序应该按已有数据的既定顺序，如果不存在既定顺序再按照默认顺序
	var attrInOrder = [];	//排序模型属性的数组
	if (!MyUtilJs.isEmpty(ov)) {
		var temp1 = {};
		for (var c in fmdc.models[modelName].attrs) {
			temp1[c] = true;
		}
		for (var i in ov) {
			if (temp1[ov[i].id]) {//如果属性在模型中有，则添加到排序数组
				attrInOrder.push(ov[i].id);
				delete temp1[ov[i].id];//添加过的删除
			}
		}
		for (var c in temp1) {	//没有配置过的属性，增加到最后
			attrInOrder.push(c);
		}
	} else {
		for (var c in fmdc.models[modelName].attrs) {
			attrInOrder.push(c);
		}
	}
	
	//加载模型所有列
	var colorro = "#f6fcff";
	var colored = "#ffffff";
	var rownum = 1;
	for (var i in attrInOrder) {
		var c = attrInOrder[i];
		var type = fmdc.models[modelName].attrs[c].type;
		ragrid.addRow(c, [rownum++, c, fmd_i18n_modules.dhxgrid.enu1names[type], fmdc.models[modelName].attrs[c].desc_zh, fmdc.models[modelName].attrs[c].desc_en,
		                  null, null, null, null, 0, null, null, null, null, null, 0]);
		ragrid.setRowColor(c, colorro);
		ragrid.cells(c, idxZH).setBgColor(colored);
		ragrid.cells(c, idxEN).setBgColor(colored);
		ragrid.cells(c, idxDEFAULT).setBgColor(colored);
		ragrid.cells(c, idxHIDDEN).setBgColor(colored);
		ragrid.cells(c, idxWIDTH).setBgColor(colored);
		ragrid.cells(c, idxALIGN).setBgColor(colored);
		ragrid.cells(c, idxSORT).setBgColor(colored);
//		ragrid.cells(c, idxMETA).setBgColor(colored);
//		ragrid.cells(c, idxMETASOURCE).setBgColor(colored);
		ragrid.cells(c, idxREADONLY).setBgColor(colored);
		ragrid.cells(c, idxZH).setAttribute("validate", "NotEmpty");
		ragrid.cells(c, idxEN).setAttribute("validate", "NotEmpty");
		ragrid.cells(c, idxWIDTH).setAttribute("validate", "ValidDhxWidth");
		//bind editor by type
		switch(type) {
			case "string":
				//editortype
				ragrid.grid_bindCombo(c, idxEDITORTYPE, 
						[["ro", fmd_i18n_modules.dhxgrid.rotext],["ed", fmd_i18n_modules.dhxgrid.inputtext],["coro",fmd_i18n_modules.dhxgrid.coro],["ch",fmd_i18n_modules.dhxgrid.ch]], 
						{"comboSize":10, "comboWidth": 120}, 
						"ed");
				ragrid.cells(c, idxEDITORTYPE).setBgColor(colored);
				//width
				ragrid.cells(c, idxWIDTH).setValue(100);
				//align
				ragrid.grid_bindCombo(c, idxALIGN, 
						[["left", fmd_i18n_modules.dhxgrid.enualign_left],["right",fmd_i18n_modules.dhxgrid.enualign_right],["center",fmd_i18n_modules.dhxgrid.enualign_center]], 
						{"comboSize":10, "comboWidth": 120}, 
						"left");
				//sorting
				ragrid.grid_bindCombo(c, idxSORT, 
						[["na", fmd_i18n_modules.dhxgrid.enusort_no],["int",fmd_i18n_modules.dhxgrid.enusort_int],["str",fmd_i18n_modules.dhxgrid.enusort_str]], 
						{"comboSize":10, "comboWidth": 120}, 
						"str");
				//meta
				ragrid.grid_bindCombo(c, idxMETA, 
						[["none", fmd_i18n_modules.dhxgrid.none],["dataprovider-dict", fmd_i18n_modules.dhxgrid.dict],["dataprovider-restsrv",fmd_i18n_modules.dhxgrid.restsrv]], 
						{"comboSize":10, "comboWidth": 120}, 
						"none");
				ragrid.cells(c, idxMETA).setBgColor(colored);
				//maxlength
				ragrid.cells(c, idxMAXLENGTH).setValue(fmdc.models[modelName].attrs[c].length);
				break;
			case "datetime":
				//editortype
				ragrid.setCellExcellType(c,idxEDITORTYPE,"pairro");
				ragrid.cells(c, idxEDITORTYPE).setValue("dhxCalendar"+pairro_spliter+fmd_i18n_modules.dhxgrid.datepicker);
				//width
				ragrid.cells(c, idxWIDTH).setValue(130);
				//align
				ragrid.grid_bindCombo(c, idxALIGN, 
						[["left", fmd_i18n_modules.dhxgrid.enualign_left],["right",fmd_i18n_modules.dhxgrid.enualign_right],["center",fmd_i18n_modules.dhxgrid.enualign_center]], 
						{"comboSize":10, "comboWidth": 120}, 
						"center");
				//sorting
				ragrid.grid_bindCombo(c, idxSORT, 
						[["na", fmd_i18n_modules.dhxgrid.enusort_no],["str",fmd_i18n_modules.dhxgrid.enusort_str]], 
						{"comboSize":10, "comboWidth": 120}, 
						"str");
				//format
				ragrid.grid_bindCombo(c, idxFORMAT, [["date",fmd_i18n_modules.datepicker.format_date]], 
						{"comboSize":10, "comboWidth": 120}, 
						"date");
				ragrid.cells(c, idxFORMAT).setBgColor(colored);
				//maxlength
				ragrid.cells(c, idxMAXLENGTH).setValue('19');
				break;
			case "int":
				//editortype
				ragrid.grid_bindCombo(c, idxEDITORTYPE, 
						[["ed", fmd_i18n_modules.dhxgrid.inputtext],["jquispinner",fmd_i18n_modules.dhxgrid.jquispinner],["ch",fmd_i18n_modules.dhxgrid.ch]], 
						{"comboSize":10, "comboWidth": 120}, 
						"ed");
				ragrid.cells(c, idxEDITORTYPE).setBgColor(colored);
				//width
				ragrid.cells(c, idxWIDTH).setValue(60);
				//align
				ragrid.grid_bindCombo(c, idxALIGN, 
						[["left", fmd_i18n_modules.dhxgrid.enualign_left],["right",fmd_i18n_modules.dhxgrid.enualign_right],["center",fmd_i18n_modules.dhxgrid.enualign_center]], 
						{"comboSize":10, "comboWidth": 120}, 
						"right");
				//sorting
				ragrid.grid_bindCombo(c, idxSORT, 
						[["na", fmd_i18n_modules.dhxgrid.enusort_no],["int",fmd_i18n_modules.dhxgrid.enusort_int]], 
						{"comboSize":10, "comboWidth": 120}, 
						"int");
				//meta
				ragrid.grid_bindCombo(c, idxMETA, 
						[["none", fmd_i18n_modules.dhxgrid.none],["dataprovider-dict", fmd_i18n_modules.dhxgrid.dict],["dataprovider-restsrv",fmd_i18n_modules.dhxgrid.restsrv]], 
						{"comboSize":10, "comboWidth": 120}, 
						"none");
				ragrid.cells(c, idxMETA).setBgColor(colored);
				//maxlength
				ragrid.cells(c, idxMAXLENGTH).setValue('10');
				break;
			case "number":
				//editortype
				ragrid.grid_bindCombo(c, idxEDITORTYPE, 
						[["ed", fmd_i18n_modules.dhxgrid.inputtext],["jquispinner",fmd_i18n_modules.dhxgrid.jquispinner]], 
						{"comboSize":10, "comboWidth": 120}, 
						"ed");
				ragrid.cells(c, idxEDITORTYPE).setBgColor(colored);
				//width
				ragrid.cells(c, idxWIDTH).setValue(60);
				//align
				ragrid.grid_bindCombo(c, idxALIGN, 
						[["left", fmd_i18n_modules.dhxgrid.enualign_left],["right",fmd_i18n_modules.dhxgrid.enualign_right],["center",fmd_i18n_modules.dhxgrid.enualign_center]], 
						{"comboSize":10, "comboWidth": 120}, 
						"right");
				//sorting
				ragrid.grid_bindCombo(c, idxSORT, 
						[["na", fmd_i18n_modules.dhxgrid.enusort_no],["int",fmd_i18n_modules.dhxgrid.enusort_int]], 
						{"comboSize":10, "comboWidth": 120}, 
						"int");
				//maxlength
				var maxl1 = parseInt(fmdc.models[modelName].attrs[c].length) + parseInt(fmdc.models[modelName].attrs[c].scale)+(parseInt(fmdc.models[modelName].attrs[c].scale)>0?1:0);
				ragrid.cells(c, idxMAXLENGTH).setValue(''+maxl1);
				break;
			case "text":
				//editortype
				ragrid.setCellExcellType(c,idxEDITORTYPE,"pairro");
				ragrid.cells(c, idxEDITORTYPE).setValue("ed"+pairro_spliter+fmd_i18n_modules.dhxgrid.inputtext);
				//width
				ragrid.cells(c, idxWIDTH).setValue(100);
				//align
				ragrid.grid_bindCombo(c, idxALIGN, 
						[["left", fmd_i18n_modules.dhxgrid.enualign_left],["right",fmd_i18n_modules.dhxgrid.enualign_right],["center",fmd_i18n_modules.dhxgrid.enualign_center]], 
						{"comboSize":10, "comboWidth": 120}, 
						"left");
				//sorting
				ragrid.grid_bindCombo(c, idxSORT, 
						[["na", fmd_i18n_modules.dhxgrid.enusort_no],["int",fmd_i18n_modules.dhxgrid.enusort_int],["str",fmd_i18n_modules.dhxgrid.enusort_str]], 
						{"comboSize":10, "comboWidth": 120}, 
						"str");
				break;
		}
		//validate
//		ragrid.grid_bindCombo(c, idxVALIDATE, fmdmeta_prop.runtime_validators_dhxgrid, 
//				{"comboSize":20, "comboWidth": 120, "editable":true}, 
//				"none");
		ragrid.setCellExcellType(c,idxVALIDATE,"btnex");
		var valiConfig = {
				"displayValue" : "displayValue",
				"onclick" : fmdmeta_prop.func.dhxgrid.setColumnsValidation
		};
		ragrid.cells(c, idxVALIDATE).setConfig(valiConfig);
		ragrid.cells(c, idxVALIDATE).setValue(null);
		ragrid.cells(c, idxVALIDATE).setBgColor(colored);
	}
	
	//bind onCellChanged
	ragrid.attachEvent("onCellChanged", function(rid,cInd,nv){
		if (cInd==idxMETA && nv) {
			if (nv=="none") {
				ragrid.setCellExcellType(rid,idxMETASOURCE,"ro");
				ragrid.cells(rid, idxMETASOURCE).setBgColor(colorro);
				ragrid.cells(rid, idxMETASOURCE).setAttribute("validate", null);
				ragrid.cells(rid, idxMETASOURCE).setValue(null);
			} else {
				if (nv=='dataprovider-dict') {
					ragrid.setCellExcellType(rid,idxMETASOURCE,"btnex");
					ragrid.cells(rid,idxMETASOURCE).setConfig({"displayValue":"displayValue",
						"onclick":function(rId,cId){fmdmeta_prop.func.selectDict(rId,cId,ragrid)}});
					ragrid.cells(rid,idxMETASOURCE).setValue(null);
					ragrid.cells(rid, idxMETASOURCE).setAttribute("validate", "NotEmptyObject");
				} else {
					ragrid.setCellExcellType(rid,idxMETASOURCE,"btnex");
					ragrid.cells(rid,idxMETASOURCE).setConfig({"displayValue":"displayValue",
						"onclick":function(rId,cId){fmdmeta_prop.func.selectService(rId,cId,ragrid)}});
					ragrid.cells(rid,idxMETASOURCE).setValue(null);
					ragrid.cells(rid, idxMETASOURCE).setAttribute("validate", "NotEmptyObject");
				}
			}
		} else if (cInd==idxEDITORTYPE) {
			if (nv=='ro') {
				ragrid.setCellExcellType(rid,idxVALIDATE,"ro");
				ragrid.cells(rid, idxVALIDATE).setValue(null);
			} else {
				ragrid.setCellExcellType(rid,idxVALIDATE,"btnex");
				var valiConfig = {
						"displayValue" : "displayValue",
						"onclick" : fmdmeta_prop.func.dhxgrid.setColumnsValidation
				};
				ragrid.cells(rid, idxVALIDATE).setConfig(valiConfig);
				ragrid.cells(rid, idxVALIDATE).setValue(null);
				ragrid.cells(rid, idxVALIDATE).setBgColor(colored);
			}
			if (nv=='coro') {
				
			} else {
				ragrid.cells(rid, idxMETA).setValue('none');
				ragrid.cells(rid, idxMETASOURCE).setValue(null);
			}
		} else if (cInd==idxREADONLY) {
			if (nv=='1' || nv==1) {
				ragrid.setCellExcellType(rid,idxVALIDATE,"ro");
				ragrid.cells(rid, idxVALIDATE).setValue(null);
			} else {
				ragrid.setCellExcellType(rid,idxVALIDATE,"btnex");
				var valiConfig = {
						"displayValue" : "displayValue",
						"onclick" : fmdmeta_prop.func.dhxgrid.setColumnsValidation
				};
				ragrid.cells(rid, idxVALIDATE).setConfig(valiConfig);
				ragrid.cells(rid, idxVALIDATE).setValue(null);
				ragrid.cells(rid, idxVALIDATE).setBgColor(colored);
			}
		}
	});
	
	//load existing
	if (MyUtilJs.isEmpty(ov)) return;
	for (var i in ov) {
		if (ragrid.getRowIndex(ov[i].id)==-1) {
			continue;
		}
		ov[i].zh && ragrid.cells(ov[i].id, idxZH).setValue(ov[i].zh);
		ov[i].en && ragrid.cells(ov[i].id, idxEN).setValue(ov[i].en);
		if ("text"==ov[i].type && ov[i].editortype=="ed") {
			//use default
		} else if ("datetime"==ov[i].type && ov[i].editortype=="dhxCalendar") {
			//use default
		} else {
			ov[i].editortype && ragrid.cells(ov[i].id, idxEDITORTYPE).setValue(ov[i].editortype);
		}
		if ("string"==ov[i].type || "int"==ov[i].type) {
			ov[i].meta && ragrid.cells(ov[i].id, idxMETA).setValue(ov[i].meta);
			ov[i].metasource && ragrid.cells(ov[i].id, idxMETASOURCE).setValue(ov[i].metasource);
		}
		ov[i]["default"] && ragrid.cells(ov[i].id, idxDEFAULT).setValue(ov[i]["default"]);
		ov[i].hidden && ragrid.cells(ov[i].id, idxHIDDEN).setValue(ov[i].hidden);
		ov[i].width && ragrid.cells(ov[i].id, idxWIDTH).setValue(ov[i].width);
		ov[i].align && ragrid.cells(ov[i].id, idxALIGN).setValue(ov[i].align);
		ov[i].sort && ragrid.cells(ov[i].id, idxSORT).setValue(ov[i].sort);
		ov[i].format && ragrid.cells(ov[i].id, idxFORMAT).setValue(ov[i].format);
		ov[i].readonly && ragrid.cells(ov[i].id, idxREADONLY).setValue(ov[i].readonly || 0);
		if (ov[i].editortype=="ro" || ov[i].readonly=='1' || ov[i].readonly==1) {
			ragrid.setCellExcellType(ov[i].id,idxVALIDATE,"ro");
			ragrid.cells(ov[i].id, idxVALIDATE).setValue(null);
		} else {
			ragrid.setCellExcellType(ov[i].id,idxVALIDATE,"btnex");
			var valiConfig = {
					"displayValue" : "displayValue",
					"onclick" : fmdmeta_prop.func.dhxgrid.setColumnsValidation
			};
			ragrid.cells(ov[i].id, idxVALIDATE).setConfig(valiConfig);
			ragrid.cells(ov[i].id, idxVALIDATE).setBgColor(colored);
			ov[i].validate && ragrid.cells(ov[i].id, idxVALIDATE).setValue(ov[i].validate);
		}
	}
};

function importExcel(obj){
	var pos = -1;
    if(obj.value.indexOf("/") > -1){
         pos = obj.value.lastIndexOf("/")*1;
    }else if(obj.value.indexOf("\\") > -1){
         pos = obj.value.lastIndexOf("\\")*1;
    }
    var fileName =  obj.value.substring(pos+1);
    var arr=fileName.split(".");
    var fileType = arr[arr.length-1];
    
	var gid = fmdc.version.formdata.propconf[designer.getSelected().attr("id")].id;
    
    if(fileType == "xls" || fileType == "xlsx"){
    	uploadFile(obj,gid);
    }else{
    	alert("文件格式不正确，请上传Excel文档！")
    }
}   	

	fmdmeta_prop.func.dhxgrid.importExcel=function(){
		if(document.getElementById("formObj")){
			document.body.removeChild(document.getElementById("formObj"));
		}

  		 var inputObj=document.createElement('input');
		 inputObj.setAttribute('id','file');
		 inputObj.setAttribute('name','f');
		 inputObj.setAttribute('type','file');
		 inputObj.setAttribute("style",'visibility:hidden');
		 inputObj.setAttribute("onchange",'importExcel(this)');

		 var formObj=document.createElement('form');
		 formObj.setAttribute('id','formObj');
		 formObj.setAttribute('method','post');
		 formObj.setAttribute('enctype','multipart/form-data');
		 formObj.setAttribute('action',' ');
		 document.body.appendChild(formObj);
		 document.getElementById("formObj").appendChild(inputObj);

		 inputObj.click();
		 inputObj.value ;
	         
	}




	fmdmeta_prop.func.dhxgrid.exportExcel = function(rId,cId){
		//检查是否选定了数据绑定
		var modelName = fmdc.version.formdata.propconf[designer.getSelected().attr("id")].model;
		if (!modelName) {
			msg(fmd_i18n_modules.dhxgrid.msg_plsselmodel);
			return;
		}
		var ov = fmdc.version.formdata.propconf[designer.getSelected().attr("id")].gridsetting;
		var fid = fmdc.version.formdata.propconf[designer.getSelected().attr("id")].id;
		var ss = fmdc.version.formdata;
		
		var gride = {};
		gride.rest_export = fmdCtx + "/rest/excel/export";
		
		var arrs = new Array();
		for (var i in ov) {
			var id = ov[i].id;
			var zhName = ov[i].zh;
			var obj = new Object(); 
			obj.id = id;
			obj.zhName = zhName;
			arrs[i]=obj;
		}
		
		window.location.href = fmdCtx + "/rest/excel/export?formId="+formId+"&versionId="+versionId+"&gid="+fid;
//		var p = {"formId":fid,"timezoneOffset":new Date().getTimezoneOffset()};
//		var ret = doPostSyncJson(gride.rest_export, p);
//		var ret = doGetSyncJson(gride.rest_export, p);
//			if (!ret) {
//				msgErr(fmd_i18n_msg_readfail);
//				return;
//			}
	}
	

	
//properties settings for dhxgrid
fmdmeta_prop.control.dhxgrid = {
		//group for element list - basic/composite/custom/extended
		"group" : "composite",
		//control category
		"controlcategory" : "datacontrol",
		//i18n type name
		"i18ntype" : fmd_i18n_el_dhxgrid,
		//icon in element list, located in images/designer/modules/
		"icon" : "elem_dhxgrid.png",
		//html code for dragging
		innerhtml_dragging : function() {
			return '<table class="elem-grid" style="width:300px;"><tr><th>Column A</th><th>Column B</th></tr><tr><td>A</td><td>C</td></tr><tr><td>B</td><td>D</td></tr></table>';
		},
		//html code after dropped
		innerhtml_dropped : function() {
			return '<table class="elem-grid"><tr><th>Column A</th><th>Column B</th></tr><tr><td>A</td><td>C</td></tr><tr><td>B</td><td>D</td></tr></table>';
		},
		"includes-properties" : {
			"common" : fmdmeta_prop.common.all.properties,
			"controlcommon" : fmdmeta_prop.common.datacontrol.properties
		},
		"properties" : {
			"i18ntype" : {
		    	"name" : fmd_i18n_prop_selectiontype,
		    	"img" : "selection.png",
		    	"cellType" : "ro",
		    	"value" : {"default":fmd_i18n_el_dhxgrid},
		    	"displayOnly" : true,
		    	"afterProperty" : "id"
		    },
		    "model" : {
		    	"name" : fmd_i18n_modules.dhxgrid.model,
		    	"img" : "databinding.png",
		    	"cellType" : {
					"type" : "coro",
					"options":"fmdmeta_prop.models_list_sub" //initialized later, so use a reference here, call eval when use
			    },
			    "value" : {"default":""},
		    	"validator" : "NotEmpty"
		    },
		    "gridsetting" : {
		    	"name" : fmd_i18n_modules.dhxgrid.gridsetting,
		    	"img" : "gridsetting.png",
		    	"cellType" : {
    				"type" : "btnex",
    				"config" : {
	    				"onclick" : fmdmeta_prop.func.dhxgrid.columnSetting
	    			}
    			},
		    	"value" : {"default" : {}},
		    	"validator" : "NotEmptyObject",
		    	"sub" : {
		    		"paging" : {
				    	"name" : fmd_i18n_modules.dhxgrid.usepaging,
				    	"img" : "paging.png",
				    	"cellType" : "ch",
				    	"value" : { "default" : 1}
				    }
		    	}
		    },
		    "editable" : {
		    	"name" : fmd_i18n_modules.dhxgrid.editable,
		    	"img" : "editable.png",
		    	"cellType" : "ch",
		    	"value" : { "default" : 1},
		    	"conditional-sub" : {
		    		"1" : {
		    			/*"editMode" : {
					    	"name" : fmd_i18n_modules.dhxgrid.editMode,
					    	"img" : "editable.png",
					    	"cellType" : {"type":"coro",
						    	"options":[["editInline",fmd_i18n_modules.dhxgrid.editInline],
									         ["editInPopup",fmd_i18n_modules.dhxgrid.editInPopup]
										  	]
							},
					    	"value" : {"default":"editInline"}
					    },*/
					    "hlChanged" : {
					    	"name" : fmd_i18n_modules.dhxgrid.hlChanged,
					    	"img" : "hlChanged.png",
					    	"cellType" : "ch",
					    	"value" : {"default":0}
					    },
					    "emptyrows" : {
					    	"name" : fmd_i18n_modules.dhxgrid.emptyrows,
					    	"img" : "databinding.png",
					    	"tooltip" : fmd_i18n_modules.dhxgrid.tooltip_emptyrows,
					    	"cellType" : "ed",
						    "value" : {"default":0},
						    "validator" : "ValidPositiveInteger"
					    }
		    		}
		    	}
		    },
		       "allowImExport" : {
		    	"name" : fmd_i18n_modules.dhxgrid.allowExcel,
		    	"img" : "Excel_16px.png",
		    	"cellType" : "ch",
		    	"value" : {"default":"0"}
/*		    	"conditional-sub" : {
				    "1" : {
				    	"import" : {
							"name" : fmd_i18n_modules.dhxgrid.importEx,
							"img" : "Excel_16px.png",
							"cellType" : {
								"type" : "btnex",
				    				"config" : {
					    				"onclick" : fmdmeta_prop.func.dhxgrid.importExcel
					    			}
								}
							},			
						"export" : {
							"name" : fmd_i18n_modules.dhxgrid.exportEx,
							"img" : "Excel_16px.png",
							"cellType" : {
								"type" : "btnex",
			    				"config" : {
				    				"onclick" :fmdmeta_prop.func.dhxgrid.exportExcel
				    				}
				    			}
						}
				    }
		    	}*/
		    }
		},
	
		"includes-events" : {
			"common" : fmdmeta_prop.common.all.events
		},
		"abandon-properties" : ["tiprow_controlcommon","disabled","hideLabel"],
		"events" : {
			"afterinit" : {
				"name" : fmd_i18n_modules.dhxgrid.event_afterinit,
				"arguments" : {
					"e" : fmd_i18n_ev_eventobj,
					"thisgrid" : fmd_i18n_modules.dhxgrid.thisgrid
				}
			},
			"beforeload" : {
				"name" : fmd_i18n_modules.dhxgrid.event_beforeload,
				"arguments" : {
					"e" : fmd_i18n_ev_eventobj,
					"data" : fmd_i18n_modules.dhxgrid.griddata
				}
			},
			"afterload" : {
				"name" : fmd_i18n_modules.dhxgrid.event_afterload,
				"arguments" : {
					"e" : fmd_i18n_ev_eventobj,
					"data" : fmd_i18n_modules.dhxgrid.griddata
				}
			}
		},
		"abandon-events" : ["click"],
		"onApply" : function() {
			var obj = designer.getSelected();
			var tbstr = '';
			if ('1'==fmdc.grid_prop.cells("editable", fmdmeta_prop.gridconf.idx.value).getValue()) {
				tbstr = '<tr><span style="border:solid 1px;"><img src="'+resloc+'/static/images/form/designer/prop/new.gif"/>'+fmd_i18n_modules.dhxgrid.add+'</span><span style="border:solid 1px;"><img src="'+resloc+'/static/images/form/designer/prop/delete.png"/>'+fmd_i18n_modules.dhxgrid.del+'</span></tr>';
			}
			obj.html('<table class="elem-grid">'+tbstr+'<tr><th>Column A</th><th>Column B</th></tr><tr><td>A</td><td>C</td></tr><tr><td>B</td><td>D</td></tr></table>');
		},
		"propDhxGridEvents" : {
			"onEditCell" : function(stage,rId,cId,nv,ov) {
				if (stage==2 && rId=="model" && ov!=nv) {
					fmdc.grid_prop.cells("gridsetting", cId).setValue({}, true);
					//fmdc.version.formdata.propconf[designer.getSelected().attr("id")]["gridsetting"] = {};
				}
				return true;
			},
			"onCellChanged" : function(rId,cId,nv) {
				if (nv && cId==fmdmeta_prop.gridconf.idx.value) {
					if (rId=='model') {
						if (fmdc.models[nv]) {
							if (this.doesRowExist("i18nname-zh")) {
								var zh = this.cells("i18nname-zh", cId).getValue();
								if (!zh || zh==fmd_i18n_untitled) this.cells("i18nname-zh", cId).setValue(fmdc.models[nv].bodesc);
							}
							if (this.doesRowExist("i18nname-en")) {
								var en = this.cells("i18nname-en", cId).getValue();
								if (!en || en=='Untitled') this.cells("i18nname-en", cId).setValue(fmdc.models[nv].bodesc);
							}
						} else {
							this.cells(rId,cId).setValue('');
						}
					}
				}
			}
		},
		"postLoaded" : function(controlType){
			if (fmdmeta_prop.elemAttachEnabled) {
				fmdmeta_prop.control[controlType].properties["attachment"] = {
			    	"name" : fmd_i18n_prop_upattach,
			    	"cellType" : "ch",
			    	"tooltip" : fmd_i18n_prop_tip_upattach,
			    	"value" : {"default":"0"},
			    	"conditional-sub" : {
			    		"1" : {
			    			"attachmentTag" : {
			    				"name" : fmd_i18n_prop_upattachTag,
						    	"cellType" : "ed",
						    	"tooltip" : fmd_i18n_prop_tip_upattachTag,
						    	"value" : {"default":""},
						    	"validatorFunc" : function() {
						    		
						    	}
			    			},
			    			"attachmentEditable" : {
			    				"name" : fmd_i18n_prop_upattachEditable,
						    	"cellType" : "ch",
						    	"value" : {"default":"0"}
			    			}
			    		}
			    	}
			    }
			}
		}
	};


